package org.hope.lee.websocket.stomp.service;

import org.hope.lee.websocket.stomp.model.Greeting;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.messaging.simp.SimpMessagingTemplate;
import org.springframework.stereotype.Service;

@Service("sendService")
public class SendServiceImpl implements SendService {
	
	@Autowired  
	private SimpMessagingTemplate simpMessagingTemplate;
	
	@Override
	public void send() {
		while(true) {
			try {
				Thread.sleep(3000);
				simpMessagingTemplate.convertAndSend("/topic/hi", new Greeting("i miss you"));
			} catch (InterruptedException e) {
				e.printStackTrace();
			}
		}
	}
}
